package com.neusoft.my12306.controller;


import com.neusoft.my12306.common.res.CommonResult;
import com.neusoft.my12306.entity.Schedule;
import com.neusoft.my12306.service.IScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 段静迪
 * @since 2023-07-04
 */
@RestController
@RequestMapping("/s")
@CrossOrigin
public class ScheduleController {
    @Autowired
    IScheduleService scheduleService;

    @PostMapping("/mod")
    public  CommonResult modSchdeule(@RequestBody Schedule  schedule){
        return   scheduleService.modSchdeule(   schedule);
    }



    @DeleteMapping("/del/byid/{sid}")

    public CommonResult  delSchdeule( @PathVariable String sid){
        return   scheduleService.delSchdeule(  sid);
    }


    @PutMapping("/add")
    public  CommonResult addSchdeule(@RequestBody Schedule  schedule){
        return   scheduleService.addSchdeule(   schedule);
    }


//

    @GetMapping("/q/byno/{trainno}")

    public  CommonResult findByTrainno( @PathVariable String trainno){

        return  scheduleService.findByTrainno(trainno);
    }



    @GetMapping("q/all")
    public CommonResult findAll(){
        return   scheduleService.findAll();
    }

}
